package bishi.bianlifeng;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/07/06 19:22
 */
public class one {
    public static void main(String args[]){
        int[][] ints = new int[5][2];
        Scanner sc = new Scanner(System.in);
        for(int i=0;i<5;i++){
            String now = sc.nextLine();
            String[] strs = now.split("-");
            ints[i][0] = Integer.valueOf(strs[0]);
            ints[i][0] = Integer.valueOf(strs[1]);
        }
        Arrays.sort(ints,(ints1, ints2)->{return ints1[0]!=ints2[0]?ints1[0]-ints2[0]:ints1[1]-ints2[1];});
        int[] now = ints[0];
        for(int i=1;i<5;i++){
            if(ints[i][0]<=now[1]){
                now[1] = ints[i][1];
            }else{
                System.out.println(now[0]+"-"+now[1]);
                now = ints[i];
            }
        }
        System.out.println(now[0]+"-"+now[1]);
    }
}
